package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 销售出库产品，售价和折扣列枚举
 *
 * @author chaoxiong.lei
 * @date 2019/2/28 20:43
 * @since v1.0
 */
@Getter
public enum OutstockSaleRelativeConstantEnum {
    /**
     * 售价
     */
    PRODUCT_PRICE("saleProductPrice", "enum.outstockSaleRelativeConstant.name.product_price", 1),
    /**
     * 售价小计
     */
    SUBTOTAL("saleSubtotal", "enum.outstockSaleRelativeConstant.name.subtotal", 1),
    /**
     * 单价
     */
    PRICE("salePrice", "enum.outstockSaleRelativeConstant.name.price", 1),
    /**
     * 折扣
     */
    DISCOUNT("saleDiscount", "enum.outstockSaleRelativeConstant.name.discount", 1),
    /**
     * 出库数量总计
     */
    OUTSTOCK_AMOUNT("outNumTotal","enum.outstockSaleRelativeConstant.name.outstock_amount", 0),
    /**
     * 出库成本总计
     */
    OUTSTOCK_COST_AMOUNT("outProductCostTotal","enum.outstockSaleRelativeConstant.name.outstock_cost_amount", 0),
    /**
     * 产品售价合计
     */
    SALE_PRICE_AMOUNT("priceTotal","enum.outstockSaleRelativeConstant.name.sale_price_amount", 0);


    /** 枚举描述 --英文名称*/
    private final String alias;

    /** 枚举信息--中文名称 */
    private final String name;

    /**
     * 是否展示在产品行，1：展示；0：不展示
     */
    private final Integer productShow;

    private OutstockSaleRelativeConstantEnum(String alias, String name, Integer productShow) {
        this.alias = alias;
        this.name = name;
        this.productShow = productShow;
    }

    /**
     * 获取全部枚举
     *
     * @return List<OutstockSaleRelativeConstantEnum>
     */
    public static List<OutstockSaleRelativeConstantEnum> getAllEnum() {
        List<OutstockSaleRelativeConstantEnum> list = new ArrayList<OutstockSaleRelativeConstantEnum>();
        for (OutstockSaleRelativeConstantEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取出库单产品展示的字段
     *
     * @return List<OutstockSaleRelativeConstantEnum>
     */
    public static List<OutstockSaleRelativeConstantEnum> getProductShowEnum() {
        List<OutstockSaleRelativeConstantEnum> list = new ArrayList<OutstockSaleRelativeConstantEnum>();
        for (OutstockSaleRelativeConstantEnum cache : values()) {
            if (Objects.equals(cache.getProductShow(), 1)) {
                list.add(cache);
            }
        }
        return list;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
